/*
 * @Author: wang cong wangc9832@163.com
 * @Date: 2023-08-24 09:26:26
 * @LastEditors: wang cong wangc9832@163.com
 * @LastEditTime: 2023-12-28 15:33:45
 * @FilePath: /ams_kt_front/src/api/asset/amsBuilding.ts
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import { BasicFetchResult } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';
import { downloadBlob } from '@/utils/file/download';
const api = '/amsBuilding';
// 楼栋_增加
export const add = (params?: any) =>
  defHttp.post({ url: api + '/add', params });
// 楼栋_删除
export const del = (ids: string[]) =>
  defHttp.post({ url: api + '/delete', params: ids });
// 楼栋_编辑
export const edit = (params?: any) =>
  defHttp.post({ url: api + '/edit', params });
// 单条查询
export const detail = (id?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/detail/' + id });

// 楼栋_不分页列表查询
export const list = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({
    url: api + '/list',
    params,
  });
//楼栋_分页查询
export const page = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({
    url: api + '/page',
    params,
  });
// 导出
export const exp = (params?: any) => {
  return new Promise<void>((resolve, reject) => {
    defHttp
      .get(
        { responseType: 'blob', url: api + '/export', params },
        { isReturnNativeResponse: true },
      )
      .then((res) => {
        downloadBlob(res);
        resolve();
      })
      .catch(() => {
        reject();
      });
  });
};
// 楼层_不分页列表查询
export const detailList = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({
    url: '/amsBuildingDetail/list',
    params,
  });
// 楼层_删除
export const detailDelete = (id: string[]) =>
  defHttp.post({ url: '/amsBuildingDetail/delete/' + id });
